import React, { Component } from 'react'
import './Components.less';
import moment from 'moment';
export default class Table extends Component<any, any> {
    render() {
        const { subjects, duration } = this.props;
        const userinfo = JSON.parse(localStorage.getItem('userinfo') || '{}')
        const nowDate = moment().format('YYYY-MM-DD HH:mm:ss');
        const tip = () => {
            const host = window.location.host;
            if (host === 'dytzsbpx.shejiyuan.com') return '本证明由东营市特种设备协会在线培训学习平台统计出具，查询网址：dytx.shejiyuan.com'
            if (host === 'qdtzsbxh.shejiyuan.com') return '本证明由青岛市特种设备协会在线培训学习平台统计出具，查询网址：qdxiehui.shejiyuan.com'
            if (host === 'tzsbpx.shejiyuan.com') return '本证明由特种设备作业人员在线培训学习系统统计出具，查询网址：qdtzsbpx.shejiyuan.com'
            if (host === 'anshun.shejiyuan.com') return '本证明由安顺特种设备作业人员在线学习平台统计出具，查询网址：anshunbm.shejiyuan.com'
            if (host === 'hengtai.shejiyuan.com') return '本证明由恒泰特种设备作业人员在线学习平台统计出具，查询网址：hengtaibm.shejiyuan.com'
            if (host === 'xuexi.shejiyuan.com') return '本证明由特种设备作业人员在线培训学习系统统计出具，查询网址：baoming.shejiyuan.com'
            if (host === 'sxhgxh.shejiyuan.com') return '本证明由山西省化学工业协会统计出具，查询网址：sxhgbm.shejiyuan.com'

            return '本证明由特种设备作业人员在线培训学习系统统计出具，查询网址：baoming.shejiyuan.com'
        }
        return (
            <div id="table" style={{ display: 'block' }} >
                <p style={{ textAlign: 'center', fontSize: 20, fontWeight: 'bold', marginBottom: 40 }}>特种设备作业人员培训证明</p>
                <table border="1" cellSpacing="0" cellPadding="0" style={{margin:'auto'}}>
                    <tbody>
                        <tr style={{ overflow: 'hidden' }}>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={1}>姓名</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}>{userinfo.name}</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5, width: 120 }} colSpan={2}>培训科目</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}>{subjects}</td>
                        </tr>
                        <tr>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={1}>证件类型</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}>身份证</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5, width: 120 }} colSpan={2}>证件号码</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}>{userinfo.id_number}</td>
                        </tr>
                        <tr>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={1}>工作单位</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}></td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5, width: 120 }} colSpan={2}>联系电话</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}>{userinfo.phone}</td>
                        </tr>
                        <tr>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={1}>学习时间</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}>{userinfo.created_ats} - {nowDate}</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5, width: 120 }} colSpan={2}>学习时长</td>
                            <td style={{ height: 30, lineHeight: '30px', padding: 5 }} colSpan={2}>{(duration / 60).toFixed(2)}小时</td>
                        </tr>
                        <tr>
                            <td style={{ padding: 5 }} colSpan={3}>
                                {tip()}
                            </td>
                            <td style={{ padding: 5 }} colSpan={5}>
                                <img style={{ width: 100, height: 100, float: 'right', marginRight: 20 }} src="https://www.shejiyuan.com/Public/images/qrcode.png" alt=" " />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        )
    }
}
